package com.demo2do.boyle.client.entity.task;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import com.demo2do.boyle.common.entity.aduser.material.MaterialImage;
import com.demo2do.boyle.common.entity.aduser.material.MaterialKeywords;
import com.demo2do.boyle.common.entity.task.Task;
import com.demo2do.boyle.common.entity.task.TaskStatus;
import com.demo2do.core.utils.DateUtils;

public class TaskDto {
	
	private Integer id;
	
	private String brandImage;
	
	private String title;
	
	private Date startDate;
	
	private Date endDate;
	
	private Date finishDate;
	
	private TaskStatus taskStatus;
	
	private String screenshot;
	
	private Integer reward;
	
	private int restDay;
	
	private String socialTypeName;
	
	private String description;
	
	private List<String> materialImages;
	
	private List<String> materialKeywords;
	
	private String link;
	
	/**
	 * The default construct
	 */
	public TaskDto() {
		
	}
	
	/**
	 * init task dto
	 * @param task
	 */
	public TaskDto(Task task) {
		this.id = task.getId();
		this.brandImage = task.getAdvertisement().getMaterial().getBrandImage();
		this.title = task.getAdvertisement().getAdTitle();
		this.startDate = task.getAdvertisement().getStartDate();
		this.endDate = task.getAdvertisement().getEndDate();
		this.finishDate = task.getEndDate();
		this.taskStatus = task.getTaskStatus();
		this.screenshot = task.getScreenshot();
		this.reward = task.getReward();
		if (TaskStatus.OVERDUE.equals(task.getTaskStatus())) {
			this.restDay = -1;
		} else {
			this.restDay = DateUtils.getIntervalDays(new Date(), endDate).size();
		}
		this.socialTypeName = task.getAdvertisement().getSocialType().getDescription();
		this.description = task.getAdvertisement().getMaterial().getDescription();
		
		List<String> materialImages = new ArrayList<String>();
		for(MaterialImage materialImage : task.getAdvertisement().getMaterial().getMaterialImages()) {
			materialImages.add(materialImage.getImage());
		}
		this.materialImages = materialImages;
		
		List<String> materialKeywords = new ArrayList<String>();
		for(MaterialKeywords materialKeyword : task.getAdvertisement().getMaterial().getMaterialKeywords()) {
			materialKeywords.add(materialKeyword.getKeywords());
		}
		this.materialKeywords = materialKeywords;
		
		this.link = task.getAdvertisement().getMaterial().getLink();
				
	}

	/**
	 * @return the id
	 */
	public Integer getId() {
		return id;
	}

	/**
	 * @return the brandImage
	 */
	public String getBrandImage() {
		return brandImage;
	}

	/**
	 * @return the title
	 */
	public String getTitle() {
		return title;
	}

	/**
	 * @return the startDate
	 */
	public Date getStartDate() {
		return startDate;
	}

	/**
	 * @return the endDate
	 */
	public Date getEndDate() {
		return endDate;
	}

	/**
	 * @return the finishDate
	 */
	public Date getFinishDate() {
		return finishDate;
	}

	/**
	 * @return the taskStatus
	 */
	public TaskStatus getTaskStatus() {
		return taskStatus;
	}

	/**
	 * @return the screenshot
	 */
	public String getScreenshot() {
		return screenshot;
	}

	/**
	 * @return the reward
	 */
	public Integer getReward() {
		return reward;
	}

	/**
	 * @return the restDay
	 */
	public int getRestDay() {
		return restDay;
	}

	/**
	 * @return the socialTypeName
	 */
	public String getSocialTypeName() {
		return socialTypeName;
	}

	/**
	 * @return the description
	 */
	public String getDescription() {
		return description;
	}

	/**
	 * @return the materialImages
	 */
	public List<String> getMaterialImages() {
		return materialImages;
	}
	
	/**
	 * @return the materialKeywords
	 */
	public List<String> getMaterialKeywords() {
		return materialKeywords;
	}

	/**
	 * @return the link
	 */
	public String getLink() {
		return link;
	}

	/**
	 * @param id the id to set
	 */
	public void setId(Integer id) {
		this.id = id;
	}

	/**
	 * @param brandImage the brandImage to set
	 */
	public void setBrandImage(String brandImage) {
		this.brandImage = brandImage;
	}

	/**
	 * @param title the title to set
	 */
	public void setTitle(String title) {
		this.title = title;
	}

	/**
	 * @param startDate the startDate to set
	 */
	public void setStartDate(Date startDate) {
		this.startDate = startDate;
	}

	/**
	 * @param endDate the endDate to set
	 */
	public void setEndDate(Date endDate) {
		this.endDate = endDate;
	}

	/**
	 * @param finishDate the finishDate to set
	 */
	public void setFinishDate(Date finishDate) {
		this.finishDate = finishDate;
	}

	/**
	 * @param taskStatus the taskStatus to set
	 */
	public void setTaskStatus(TaskStatus taskStatus) {
		this.taskStatus = taskStatus;
	}

	/**
	 * @param screenshot the screenshot to set
	 */
	public void setScreenshot(String screenshot) {
		this.screenshot = screenshot;
	}

	/**
	 * @param reward the reward to set
	 */
	public void setReward(Integer reward) {
		this.reward = reward;
	}

	/**
	 * @param restDay the restDay to set
	 */
	public void setRestDay(int restDay) {
		this.restDay = restDay;
	}

	/**
	 * @param socialTypeName the socialTypeName to set
	 */
	public void setSocialTypeName(String socialTypeName) {
		this.socialTypeName = socialTypeName;
	}

	/**
	 * @param description the description to set
	 */
	public void setDescription(String description) {
		this.description = description;
	}

	/**
	 * @param materialImages the materialImages to set
	 */
	public void setMaterialImages(List<String> materialImages) {
		this.materialImages = materialImages;
	}
	
	/**
	 * @param materialKeyword the materialKeywords to set
	 */
	public void setMaterialKeywords(List<String> materialKeywords) {
		this.materialKeywords = materialKeywords;
	}

	/**
	 * @param link the link to set
	 */
	public void setLink(String link) {
		this.link = link;
	}

}
